package com.jiajia.study.nio.chapter02;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

public class NioClient02 {
    public static void main(String[] args) throws IOException {

        SocketChannel open = SocketChannel.open();

        open.connect(new InetSocketAddress(8888));
        int read = 0;
        while (true) {
            ByteBuffer buffer = ByteBuffer.allocate(1024 * 1024);
            read += open.read(buffer);
            System.out.println("read = " + read);
            buffer.clear();
        }
    }
}
